import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import flexjson.DateTransformer;
import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

import wavenotes.model.presentation.Note;
import wavenotes.model.presentation.Presentation;
import wavenotes.model.presentation.Slide;

public class JSONTester {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Map<String,ArrayList<Note>> personNotes = new
		// HashMap<String,ArrayList<Note>>();
		// personNotes.put("slide_0", "test");

		// Map<String,List<Note>> personNotes = new
		// HashMap<String,List<Note>>();
		// List<Note> notes1 = new ArrayList<Note>();
		// notes1.add(new Note("barrusj", "Jeffrey Barrus", new Date(),
		// "notea"));
		// notes1.add(new Note("klv", "Kelv", new Date(), "noteb"));
		// notes1.add(new Note("barrusj", "Jeffrey Barrus", new Date(),
		// "notec"));
		// personNotes.put("slide_0", notes1);
		//		
		// List<Note> notes2 = new ArrayList<Note>();
		// notes2.add(new Note("barrusj", "Jeffrey Barrus", new Date(),
		// "notez"));
		// personNotes.put("slide_1", notes2);
		//		
		// System.out.println(new JSONSerializer().serialize(personNotes));

		String json = "{\"slide_0\":["
				+ "{\"participantId\":\"barrusj@googlewave.com\",\"displayName\":\"Jeffrey Barrus\",\"time\":1269467780375,\"finished\":true,\"text\":\"testing123\"},"
				+ "{\"participantId\":\"barrusj@googlewave.com\",\"displayName\":\"Jeffrey Barrus\",\"time\":1269467788052,\"finished\":true,\"text\":\"second notes\"},"
				+ "{\"participantId\":\"barrusj@googlewave.com\",\"displayName\":\"Jeffrey Barrus\",\"time\":1269467811074,\"finished\":true,\"text\":\"some more notes\"}],"
				+ "\"slide_1\":[null,null,"
				+ "{\"participantId\":\"barrusj@googlewave.com\",\"displayName\":\"Jeffrey Barrus\",\"time\":1269467798246,\"finished\":true,\"text\":\"note note\"}]}";

		// String json =
		// "{\"slide_0\":[\"test1\", \"test2\"], \"slide_1\":[\"test3\"]}";
		// Map<String,List<String>> personNotes = new
		// JSONDeserializer<Map<String,List<String>>>()
		// .use(null,HashMap.class)
		// .use("values", ArrayList.class)
		// .use("values", ArrayList.class)
		// //.use(Date.class, new DateTransformer("yyyy.MM.dd"))
		// .deserialize(json);
		//		
		// for (String key : personNotes.keySet()) {
		// System.out.println(key + " = " + personNotes.get(key));
		// }

		Map<String, ArrayList<Note>> personNotes = new JSONDeserializer<Map<String, ArrayList<Note>>>()
				.use(null, HashMap.class)
				.use("values", ArrayList.class)
				.use("values.values", Note.class)
				.deserialize(json);

		for (String key : personNotes.keySet()) {
			System.out.println(key + " = " + personNotes.get(key));
		}

		/*
		 * Presentation newPresentation = new
		 * JSONDeserializer<Presentation>().use(null, Presentation.class)
		 * .use("slides", ArrayList.class) .use("slides.values", Slide.class)
		 * .use(Date.class, new DateTransformer("yyyy.MM.dd"))
		 * .deserialize(jsonString);
		 */
	}
}
